Skip to content

Cli: headless 6502 frontend (assemble/run/disasm/hexdump) - #166

Merged
JumpLink merged 1 commit into
mainfrom
feat/cli-spike
Jul 4, 2026
Merged

Cli: headless 6502 frontend (assemble/run/disasm/hexdump)#166
JumpLink merged 1 commit into
mainfrom
feat/cli-spike

Conversation

@JumpLink

@JumpLink JumpLink commented Jul 4, 2026

Copy link
Copy Markdown
Owner

A command-line frontend for Learn6502 — the "fourth frontend" alongside the GNOME, web and Android apps. The key idea (per discussion): it is built on the same shared libraries rather than sitting underneath them — @learn6502/core (assembler + simulator) and @learn6502/common-ui (the DisplayWidget contract, createSimulatorStack, DEFAULT_COLOR_PALETTE). The GUIs remain library consumers; nothing depends on this CLI. It doubles as an executable proof that the core is genuinely UI-independent.

Commands

learn6502 assemble <file.asm>   Assemble and report the result
learn6502 run <file.asm>        Assemble, run, and render the display
learn6502 hexdump <file.asm>    Assemble and print a hexdump
learn6502 disasm <file.asm>     Assemble and print the disassembly

The display is just another platform

AnsiDisplay implements the same DisplayWidget interface the GTK (Gtk.DrawingArea+cairo), web (<canvas>) and Android displays implement. The 32×32 grid of memory $0200-$05FF prints as truecolor ANSI using the upper half-block (foreground = top pixel, background = bottom), so the screen stays roughly square in a terminal. run drives the simulator synchronously via debugExecStep() (with a step cap for programs that loop or await input) rather than the GUI's setInterval loop.

Verified

Built with gjsify build --app node (node-free-ready) and exercised end-to-end:

  • assemble"Code assembled successfully, 11 bytes."
  • run on a colour-chart program → renders all 16 palette colours as vertical bands, "Program completed after 1026 steps."
  • hexdump0600: a2 00 a5 fe 9d 00 02 e8 d0 f8 00
  • disasm → full annotated disassembly table

The batch commands (assemble/disasm/hexdump) are thin wrappers over core; only run reaches for common-ui — an honest split between batch and interactive use. This is a spike: it validates the decoupling and the ANSI-display approach. Natural follow-ups: an interactive debug REPL (readline stepper over the existing debuggerController), stdin gamepad input, binary I/O (-o out.bin), and a --app gjs build.

A command-line frontend for Learn6502 — the "fourth frontend" alongside the
GNOME, web and Android apps, built on the SAME shared libraries rather than
sitting underneath them: `@learn6502/core` (assembler + simulator) and
`@learn6502/common-ui` (the `DisplayWidget` contract, `createSimulatorStack`,
`DEFAULT_COLOR_PALETTE`). It doubles as an executable proof that the core is
genuinely UI-independent.

Commands (`packages/cli/src/`):
- `assemble <file.asm>` — assemble and print the assembler's own result message
- `run <file.asm>`      — assemble, run to completion (via `debugExecStep`, with
                          a step cap for programs that loop/await input), and
                          render the display
- `hexdump <file.asm>`  — assemble and print a hexdump
- `disasm <file.asm>`   — assemble and print the disassembly

`AnsiDisplay` implements the shared `DisplayWidget` interface — the terminal is
just another platform. The 32×32 grid of memory `$0200-$05FF` prints as
truecolor ANSI using the upper half-block `▀` (foreground = top pixel,
background = bottom), so the screen stays roughly square. Built node-free-ready
via `gjsify build --app node`.

The batch commands (assemble/disasm/hexdump) are thin wrappers over core; only
`run` reaches for common-ui — an honest split between batch and interactive use.
The GUIs remain library consumers; nothing depends on this CLI.
@JumpLink
JumpLink merged commit 60ecb99 into main Jul 4, 2026
3 checks passed
@JumpLink
JumpLink deleted the feat/cli-spike branch July 4, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant